package com.yuqian.JavaSe.thread.cap1.title2;

public class UnSafeThread {
	private static String userName;
	private static String password;
	
	public synchronized static void  doPost(String name,String word) throws InterruptedException{
		userName = name;
		if("a".equals(name)){
			Thread.sleep(1000);
		}
		password =word;
		System.out.println("userName:"+userName+"  password:"+password);
	}
	
	public static void main(String[] args) {
		Threada a=new Threada();
		Threadb b=new Threadb();
		a.start();
		b.start();
	}
}

class Threada extends Thread{
	@Override
	public void run(){
		try {
			UnSafeThread.doPost("a", "aaa");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}

class Threadb extends Thread{
	@Override
	public void run(){
		try {
			UnSafeThread.doPost("b", "bbb");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
